function getFile()
{
	var settingsFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD",Components.interfaces.nsILocalFile);
	var filename = "weather-forecaster-settings.json";
	settingsFile.append(filename);

	return settingsFile;
}

function writeSettingsFile(file,zip,humidity,temp,wind,api)
{
	var jsonZip = '"zip":"'+zip+'"';
	var jsonHumidity = '"humidity":"'+humidity+'"';
	var jsonTemp = '"temp":"'+temp+'"';
	var jsonWind = '"wind":"'+wind+'"';
	var jsonAPI = '"api":"'+api+'"';

	var settingStr = "{"+jsonZip+","+jsonHumidity+","+jsonTemp+","+jsonWind+","+jsonAPI+"}";
	var oStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
	oStream.init(file,0x02 | 0x08 | 0x20, 00666, 0);
	oStream.write(settingStr,settingStr.length);
	oStream.close();
}

function readSettingsFile(file)
{
	var iStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
	var cStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"].createInstance(Components.interfaces.nsIConverterInputStream);
	iStream.init(file,-1,0,0);
	cStream.init(iStream,"UTF-8",0,0);
	var retval = "";
	var str = {};
	var read = 0;
	do
	{
		read=cStream.readString(0xffffffff,str);
		retval += str.value;
	} while (read != 0);

	cStream.close();
	return retval;
}

function createSettingsFile(file)
{
	writeSettingsFile(file,"22203","1","1","1","wund");	
}
